From c8230915a2ff08fed97eb0aa48c42ffeb527240f Mon Sep 17 00:00:00 2001 From: memdmp Date: Sun, 21 Sep 2025 00:19:45 +0000 Subject: feat: scope prompt for a target="_blank" --- src/routes/scope-prompt/[scopes]/+server.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/routes/scope-prompt/[scopes]/+server.ts (limited to 'src/routes/scope-prompt/[scopes]') diff --git a/src/routes/scope-prompt/[scopes]/+server.ts b/src/routes/scope-prompt/[scopes]/+server.ts new file mode 100644 index 0000000..f919b9c --- /dev/null +++ b/src/routes/scope-prompt/[scopes]/+server.ts @@ -0,0 +1,21 @@ +import { base } from '$app/paths'; +import { checkScope } from '$lib/auth'; +import { error, redirect } from '@sveltejs/kit'; + +export const GET = async (e) => { + const scopes = e.params.scopes + .split(' ') + .flatMap((v) => v.split(',')) + .flatMap((v) => v.split('+')) + .filter((v) => v); + if ( + checkScope( + await e.locals.auth(), + scopes, + true, + base + '/scope-prompt/ok/if/' + scopes.join(',') + ) + ) + throw redirect(303, base + '/scope-prompt/ok'); + else throw error(500, 'In server mode, this branch should be unreachable'); +}; -- cgit v1.2.3